<%@ page import="com.lengmou.service.UsersService" %>
<%@ page import="com.lengmou.service.impl.UsersServiceImpl" %>
<%@ page import="com.lengmou.entity.Message" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" errorPage="error.jsp" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>橘猫布偶 - 魔法集市</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <link rel="stylesheet" href="css/index.css">
    <link href="favicon.ico" rel="shortcut icon">
    <script src="js/jquery-3.1.0.js"></script>
    <script>
        $(function () {
            $("#send").click(function () {
                $.post(
                    "message",
                    {content:$("#content").val()},
                    function (date) {
                        if(date.addState>0){
                            $("#tishi").html("评价成功，感谢您的反馈！").attr("class","ui-toast-box");
                            setTimeout(function () {$("#tishi").attr("class","ui-toast-box h");location.href="message.jsp";},1000);
                        }else{
                            alert("网络连接失败，请检查您的网络")
                        }
                    }
                    ,"json"
                )
            })
        })
    </script>
</head>
<body>
<%@include file="header.jsp"%>

<div id="M" style="margin-top: 60px">
    <div class="view view-p">
    <div class="func-cmt-add-box">
        <label class="text-box">
            <div class="textarea-content-shadowbox"></div>
            <textarea id="content" name="content" cols="30" rows="1" maxlength="1000" placeholder="在这里输入评价，站长会认真阅读的" style="height: 36px;"></textarea>
        </label>
        <button id="send">发送</button>
    </div>
    <div class="mo-box func-cmts-box"><div class="head">
        <h4>评论</h4>
        <span>共 <b>${messages.size()}</b> 条评论</span>
    </div>
        <%UsersService us = new UsersServiceImpl();%>
        <%--这里开始评论循环--%>
        <c:forEach items="${messages}" var="message">
            <%
                Message message = (Message) pageContext.getAttribute("message");
                User usera = us.existsById(message.getUserid());
                pageContext.setAttribute("user",usera);
            %>
            <div class="content"><div class="item" data-id="154851" data-status="true" data-spam="${user.username}"><a class="user-box" href=""><b>${user.username}</b></a><p>${message.content}</p><time>${message.time}</time>&nbsp;</div></div>
        </c:forEach>
    </div>
</div>
</div>
<%@include file="foot.jsp"%>
<div id="tishi" class="ui-toast-box h"></div>
</body>
</html>
